<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>已签离</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/global.css">
		<link rel="stylesheet" href="../../../css/style.css">

	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">已签离</h1>
		</header>
		<div class="mui-content">
			<div class="details_con">
				<div class="clum">
					<span class="name">服务编号</span>
					<span class="txt" id="serviceNo"></span>
				</div>
				<div class="clum">
					<span class="name">提交时间</span>
					<span class="txt" id="createTime"></span>
				</div>
				<div class="clum">
					<span class="name">服务子类型</span>
					<span class="txt" id="serviceType"></span>
				</div>
				<div class="clum_arr">
					<span class="name_arr">客户名称</span>
					<span class="txt_arr" id="customerName"></span>
				</div>
				<div class="clum">
					<span class="name">客户类型</span>
					<span class="txt" id="enginnerType"></span>
				</div>
				<div class="clum">
					<span class="name">期望服务时间</span>
					<span class="txt" id="hopeBusinessHours"></span>
				</div>
				<div class="clum">
					<span class="name">服务角色</span>
					<span class="txt">
						<input class="serviceRole" name="serviceRole" type="radio" value="1" disabled="disabled">现场服务&nbsp;&nbsp;
						<input class="serviceRole" name="serviceRole" type="radio" value="2" disabled="disabled">实习
					</span>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="khxxxx">
						<em>客户详细信息</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="yqxx">
						<em>仪器详细信息</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="htxx">
						<em>合同详细信息</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="fwtzxx">
						<em>服务通知详细信息</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="tjsybjxx">
						<em>推荐使用备件详细信息</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="xxggsq">
						<em>信息更改申请</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="ckrz">
						<em>查看日志</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="ckbg">
						<em>查看报告</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="report">
						<em>Error Report&Hot Account Report</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
			</div>
			<div class="btn_box">

				<span class="fl" id="hxzcsm">还需再次上门</span>
				<span class="fr red" id="tjbg" style="display: none;">添加报告</span>
			</div>
			<div style="height: 50px;"></div>
		</div>

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">
			var ServiceNoticeId
			var serviceNo
			var planId
			var planState

			// 仪器详情用带过去
			var trainQuota
			var installationDate
			var cfda

			// 服务通知详细信息用
			var serviceType
			var isWarranty
			var troubleDescription
			var remark
			var serviceRole

			var subServiceType
			var longitude
			var latitude
			var noticeId
			var isWarranty
			var orderReceivedDate

			// report用
			var divBu
			var problem

			var complete

			(function($, doc) {
				$.init();
				$.plusReady(function() {
					// 从上一个页面取值
					var self = plus.webview.currentWebview();
					 // 获取上一个页面传过来的参数并显示到页面
					 ServiceNoticeId = self.ServiceNoticeId;
					 serviceNo = self.serviceNo;
					 planId = self.planId;
					 complete = self.complete;
					 if(complete){
					 	h('#title').html('已完成')
					 }

					 console.log("ServiceNoticeId:"+ServiceNoticeId+"	serviceNo:"+serviceNo+"	planId:"+planId)

					 // 获取详情的方法
					 getDetails();

					 // 客户详细信息
					 h("#khxxxx").tap(function(){
						 app.jumpTo("/view/service/accept/customerDetails.html", "view/service/accept/customerDetails.html",
						 {
						 	ServiceNoticeId:ServiceNoticeId,
						 	serviceNo: serviceNo,
						 	planId: planId
						 });
					 })

					 // 仪器详细信息
					 h("#yqxx").tap(function(){
						 app.jumpTo("/view/service/accept/instrumentDetails.html", "view/service/accept/instrumentDetails.html",
						 {
						 	ServiceNoticeId:ServiceNoticeId,
						 	serviceNo: serviceNo,
						 	planId: planId,
							trainQuota: trainQuota,
							installationDate: installationDate,
							cfda: cfda
						 });
					 })

					 // 合同详细信息
					 h("#htxx").tap(function(){
						 app.jumpTo("/view/service/accept/contractDetails.html", "view/service/accept/contractDetails.html",{
						 	serviceNo: serviceNo,
						 });
					 })

					 // 服务通知详细信息
					 h("#fwtzxx").tap(function(){
						 app.jumpTo("/view/service/accept/noticeDetails.html", "view/service/accept/noticeDetails.html",
						 {
						 	ServiceNoticeId:ServiceNoticeId,
						 	serviceNo: serviceNo,
						 	planId: planId,
							serviceType: serviceType,
							isWarranty: isWarranty,
							troubleDescription: troubleDescription,
							remark: remark
						 });
					 })

					 // 推荐使用备件详细信息
					 h("#tjsybjxx").tap(function(){
						 app.jumpTo("/view/service/accept/partDetails.html", "view/service/accept/partDetails.html",
						 {
						 	ServiceNoticeId:ServiceNoticeId,
						 	serviceNo: serviceNo,
						 	planId: planId
						 });
					 })

					 // 信息更改申请
					 h("#xxggsq").tap(function(){
						 app.jumpTo("/view/service/accept/infoUpdate.html", "view/service/accept/infoUpdate.html",
						 {
							ServiceNoticeId: ServiceNoticeId,
							serviceNo: serviceNo,
							noticeId: ServiceNoticeId,
							planId: planId
						 });
					 })

					 // 查看日志
					 h("#ckrz").tap(function(){
					 	app.jumpTo("/view/service/serviceLog/noticeLogList.html", "view/service/serviceLog/noticeLogList.html",
					 	{
					 		serviceNo: serviceNo,
							planId: planId
					 	});
					 })
					 // 查看报告
					 h("#ckbg").tap(function(){
					 	app.jumpTo("/view/service/report/work/workReportList.html", "view/service/report/work/workReportList.html",
					 	{
					 		serviceNo: serviceNo
					 	});
					 })
					 h("#report").tap(function(){
						 app.jumpTo("/view/service/report/errorhot/erroOrHot.html", "view/service/report/errorhot/erroOrHot.html",
						 {
							serviceNo: serviceNo,
							serviceType: serviceType,
							planId: planId,
							noticeId:ServiceNoticeId,
							problem: problem,
							divBu: divBu
						 });
					 })

				});

				// 获取详情的方法
				function getDetails(){
					app.showWaiting('加载中...')
					ajaxGet(BASE_URL + "cc/notice/getMyServiceNoticeDetail", {
						"ServiceNoticeId": ServiceNoticeId,
						"EnginnerId": app.getUser().enginnerId
					}, function(data) {
						app.closeWaiting()
						console.log(JSON.stringify(data))
						if (data.code == 200) {
							if(data.data!=""){
								h("#serviceNo").html(data.data[0].serviceNo);
								h("#createTime").html(data.data[0].createTime);
								h("#serviceType").html(data.data[0].subServiceType);
								h("#customerName").html(data.data[0].customerName);
								planState = data.data[0].planState;
								noticeId = data.data[0].id;
								isWarranty = data.data[0].isWarranty;
								problem = data.data[0].troubleDescription;
								divBu = data.data[0].divBu;
								if(data.data[0].enginnerType==undefined || data.data[0].enginnerType==""){
									h("#enginnerType").html("无");
								}else{
									h("#enginnerType").html(data.data[0].enginnerType);
								}
								if(data.data[0].hopeBusinessHours==undefined || data.data[0].hopeBusinessHours==""){
									h("#hopeBusinessHours").html("无");
								}else{
									h("#hopeBusinessHours").html(data.data[0].hopeBusinessHours);
								}

								// 仪器详细信息页面用
								if(data.data[0].trainQuota==undefined || data.data[0].trainQuota==""){
									trainQuota = "";
								}else{
									trainQuota = data.data[0].trainQuota;
								}
								if(data.data[0].installationDate==undefined || data.data[0].installationDate==""){
									installationDate = "";
								}else{
									installationDate = data.data[0].installationDate;
								}
								if(data.data[0].cfda==undefined || data.data[0].cfda==""){
									cfda = "";
								}else{
									cfda = data.data[0].cfda;
								}

								// 服务通知详细信息页面用
								if(data.data[0].serviceType==undefined || data.data[0].serviceType==""){
									serviceType = "";
								}else{
									serviceType = data.data[0].serviceType;
								}
								if(data.data[0].subServiceType==undefined || data.data[0].subServiceType==""){
									subServiceType = "";
								}else{
									subServiceType = data.data[0].subServiceType;
								}
								if(data.data[0].isWarranty==undefined || data.data[0].isWarranty==""){
									isWarranty = "";
								}else{
									isWarranty = data.data[0].isWarranty;
								}
								if(data.data[0].troubleDescription==undefined || data.data[0].troubleDescription==""){
									troubleDescription = "";
								}else{
									troubleDescription = data.data[0].troubleDescription;
								}
								if(data.data[0].remark==undefined || data.data[0].remark==""){
									remark = "";
								}else{
									remark = data.data[0].remark;
								}

								serviceRole = data.data[0].serviceRole;
								if (serviceRole) {
									 document.querySelector(`input[name='serviceRole'][value='${serviceRole}']`).checked=true;
									 if(serviceRole=='1'){
									 	h('#tjbg').show();
									 }
								}

							}

						}else{
							app.toast(data.msg)
						}
					}, function(errorMsg) {
						console.log(JSON.stringify(errorMsg))
						app.toast(errorMsg)
					});
				}

				// 添加报告
				h("#tjbg").tap(function(){
					// app.jumpTo("/view/service/report/maintenanceReport.html", "view/service/report/maintenanceReport.html",
					// {
					// 	serviceNo: serviceNo
					// });
					//根据planID 去查询接受任务时间
					 ajaxGet(BASE_URL + "cc/PlanDetails/getDetailsById", {
					 	"id": planId
					 }, function(data) {
					 	console.log(JSON.stringify(data))
					 	if(data.code==200){
							orderReceivedDate = data.data.acceptTime
						}else{
							app.toast('获取接受任务时间失败');
						}
					 }, function(errorMsg) {
						 app.toast('获取接受任务时间失败');
					 	console.log(JSON.stringify(errorMsg))
					 });

					app.jumpTo("/view/service/report/maintenanceReport.html", "view/service/report/maintenanceReport.html",
					{
						serviceNo: serviceNo,
						planId: planId,
						planState: planState,
						noticeId: noticeId,
						orderReceivedDate:orderReceivedDate,
						isWarranty: isWarranty,
						serviceType:serviceType,
						subServiceType: subServiceType,
						problem: problem
					});
				})

				// 还需再次上门
				h("#hxzcsm").tap(function(){
					ajaxGet(BASE_URL + "cc/report/info/checkReportResult", {
						serviceNo: serviceNo
					}, function(data) {
						console.log(data)
						if(data.code==200){
							if(data.data&&data.data.length){
								app.toast('存在已完成的报告，请删除后再操作');

							}else {
								app.jumpTo("/view/service/notice/signExpectedDoor.html", "view/service/notice/signExpectedDoor.html",
										{
											serviceNo: serviceNo,
											planId: planId,
											ServiceNoticeId: ServiceNoticeId,
											serviceRole : serviceRole
										});
							}

						}
					}, function(errorMsg) {
						console.log(JSON.stringify(errorMsg))
					});

				})

			}(mui, document));
		</script>
		<!-- js代码 end -->

	</body>

</html>
